package com.ilop.permission.base;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import androidx.databinding.ViewDataBinding;

import com.ilop.permission.R;

import java.util.Objects;

/**
 * @author skygge
 * @date 6/16/22.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：底部平铺的弹出框
 */
public abstract class BottomTileDialog<B extends ViewDataBinding> extends BaseDialogFragment<B> {

    @Override
    public void onStart() {
        Window window = Objects.requireNonNull(this.getDialog()).getWindow();
        window.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.windowAnimations = R.style.BottomDialogAnimation;
        params.gravity = Gravity.BOTTOM;
        window.setAttributes(params);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        super.onStart();
    }
}
